﻿<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true"
    CodeFile="Users.aspx.cs" Inherits="Admin_Users" Title="Manage Users - ILE Admin" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<%@ Register TagPrefix="uc" TagName="UpdateProgress" Src="~/UserControls/UpdateProgress.ascx" %>
<%@ Register TagPrefix="uc" TagName="ModalPopupMessage" Src="~/UserControls/ModalPopupMessage.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="Server">
    <uc:UpdateProgress ID="updateProgress" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <uc:ModalPopupMessage ID="ModalPopupMessage" runat="server" />
            <h1>
                Manage Users</h1>
            <br />
            <asp:Button ID="btnOpenAddUser" runat="server" Text="Add User" Width="150" OnClick="btnOpenAddUser_Click" />
            &nbsp;&nbsp;&nbsp;
            <asp:Button ID="btnOpenEditUser" runat="server" Text="Edit User" Width="150" OnClick="btnOpenEditUser_Click" />
            &nbsp;&nbsp;&nbsp;
            <asp:Button ID="btnOpenEditClasses" runat="server" Text="Edit Classes" Width="150"
                OnClick="btnOpenEditClasses_Click" />
            <br />
            <br />
            <asp:MultiView ID="MultiViewUsers" runat="server">
                <asp:View ID="ViewAddUser" runat="server">
                    <div class="borderedBox">
                        <h3>
                            Add User</h3>
                        <p>
                            Add a user by filling in the blanks and then hitting the &quot;Add User&quot; button.
                        </p>
                        <table>
                            <tr>
                                <td class="tableLeftHeader">
                                    First Name * :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtAddUserFirstName" runat="server" MaxLength="50" />
                                    <asp:RequiredFieldValidator ID="rfValidatorAddFirstName" runat="server" ControlToValidate="txtAddUserFirstName"
                                        ErrorMessage="* First Name is Required." ValidationGroup="AddUser" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Last Name * :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtAddUserLastName" runat="server" MaxLength="50" />
                                    <asp:RequiredFieldValidator ID="rfValidatorAddLastName" runat="server" ControlToValidate="txtAddUserLastName"
                                        ErrorMessage="* Last Name is Required." ValidationGroup="AddUser" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Network ID * :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtAddUserNetworkID" runat="server" MaxLength="100" />
                                    <asp:RequiredFieldValidator ID="rfValidatorAddNetworkID" runat="server" ControlToValidate="txtAddUserNetworkID"
                                        ErrorMessage="* Network ID is Required." ValidationGroup="AddUser" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Email * :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtAddUserEmail" runat="server" MaxLength="100" />
                                    <asp:RequiredFieldValidator ID="rfValidatorAddEmail" runat="server" ControlToValidate="txtAddUserEmail"
                                        ErrorMessage="* Email is Required." ValidationGroup="AddUser" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Is Active :
                                </td>
                                <td class="tableItem">
                                    <asp:CheckBox ID="chkboxAddUserIsActive" runat="server" Checked="true" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Is Admin :
                                </td>
                                <td class="tableItem">
                                    <asp:CheckBox ID="chkboxAddUserIsAdmin" runat="server" Checked="false" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <asp:Button ID="btnAddUser" runat="server" Text="Add User" Width="150" OnClick="btnAddUser_Click"
                                        ValidationGroup="AddUser" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </asp:View>
                <asp:View ID="ViewEditUser" runat="server">
                    <div class="borderedBox">
                        <h3>
                            Edit User</h3>
                        <p>
                            Edit a user by<br />
                            1. Selecting the user role below.<br />
                            2. Selecting the user from the drop down menu.<br />
                            3. Edit the information.<br />
                            4. Htting the &quot;Update&quot; or &quot;Delete&quot; button.
                        </p>
                        <table>
                            <tr>
                                <td class="tableLeftHeader">
                                    Account Type * :
                                </td>
                                <td class="tableItem">
                                    <asp:RadioButtonList ID="rdobtnEditUserAccountType" runat="server" RepeatDirection="Horizontal"
                                        AutoPostBack="true" OnSelectedIndexChanged="rdobtnEditUserAccountType_SelectedIndexChanged">
                                        <asp:ListItem Selected="False" Text="Non-Institute" Value="NonInstitut" />
                                        <asp:ListItem Selected="False" Text="Instructors" Value="Instructor" />
                                        <asp:ListItem Selected="False" Text="Administrators" Value="Admin" />
                                    </asp:RadioButtonList>
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    User Name * :
                                </td>
                                <td class="tableItem">
                                    <asp:DropDownList ID="ddlistEditUserUsersList" runat="server" AutoPostBack="true"
                                        OnSelectedIndexChanged="ddlistEditUserUsersList_SelectedIndexChanged" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    First Name * :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtEditUserFirstName" runat="server" MaxLength="50" />
                                    <asp:RequiredFieldValidator ID="rfValidatorEditFirstName" runat="server" ControlToValidate="txtEditUserFirstName"
                                        ErrorMessage="* First Name is Required." ValidationGroup="EditUser" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Last Name * :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtEditUserLastName" runat="server" MaxLength="50" />
                                    <asp:RequiredFieldValidator ID="rfValidatorEditLastName" runat="server" ControlToValidate="txtEditUserLastName"
                                        ErrorMessage="* Last Name is Required." ValidationGroup="EditUser" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Network ID * :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtEditUserUsername" runat="server" MaxLength="100" />
                                    <asp:RequiredFieldValidator ID="rfValidatorEditNetworkID" runat="server" ControlToValidate="txtEditUserUsername"
                                        ErrorMessage="* Network ID is Required." ValidationGroup="EditUser" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Email * :
                                </td>
                                <td class="tableItem">
                                    <asp:TextBox ID="txtEditUserEmail" runat="server" MaxLength="100" />
                                    <asp:RequiredFieldValidator ID="rfValidatorEditEmail" runat="server" ControlToValidate="txtEditUserEmail"
                                        ErrorMessage="* Email is Required." ValidationGroup="EditUser" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Is Active :
                                </td>
                                <td class="tableItem">
                                    <asp:CheckBox ID="chkboxEditUserIsActive" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td class="tableLeftHeader">
                                    Is Admin :
                                </td>
                                <td class="tableItem">
                                    <asp:CheckBox ID="chkboxEditUserIsAdmin" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <asp:Button ID="btnEditUser" runat="server" Text="Update" Width="100" OnClick="btnEditUser_Click"
                                        ValidationGroup="EditUser" />
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    <asp:Button ID="btnDeleteUser" runat="server" Text="Delete User" Width="150" OnClick="btnDeleteUser_Click"
                                        Enabled="false" />
                                    <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="btnDeleteUser"
                                        ConfirmText="Are you sure you want to delete the user?" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </asp:View>
                <asp:View ID="ViewEditClasses" runat="server">
                    <div class="borderedBox">
                        <h3>
                            Edit Instructors &amp; Class Relationships</h3>
                        <br />
                        <asp:Label ID="lblEditClassMsg" runat="server" Text="<center><h4>No Instructors has been added</h4></center>" />
                        <table>
                            <tr>
                                <td class="tableLeftHeader">
                                    Filter By Account Type:
                                </td>
                                <td>
                                    <asp:RadioButtonList ID="rdobtnsFilterAccountType" runat="server" AutoPostBack="true"
                                        RepeatDirection="Horizontal" OnSelectedIndexChanged="rdobtnsFilterAccountType_SelectedIndexChanged">
                                        <asp:ListItem Value="Instructor" Selected="True">Instructors</asp:ListItem>
                                        <asp:ListItem Value="Admin">Administrators</asp:ListItem>
                                    </asp:RadioButtonList>
                                </td>
                            </tr>
                        </table>
                        <asp:GridView ID="GridViewInstructors" runat="server" AllowPaging="True" AllowSorting="True"
                            AutoGenerateColumns="False" CellPadding="4" DataKeyNames="UserID" DataSourceID="ObjectDataSourceInstructors"
                            ForeColor="#333333" GridLines="None" Width="520px" OnSelectedIndexChanged="GridViewInstructors_SelectedIndexChanged">
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <Columns>
                                <asp:CommandField ShowSelectButton="True" />
                                <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
                                <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
                                <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
                                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                                <asp:CheckBoxField DataField="IsEnabled" HeaderText="Enabled?" SortExpression="IsEnabled">
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:CheckBoxField>
                            </Columns>
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#999999" />
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        </asp:GridView>
                        <br />
                        <asp:GridView ID="GridViewClasses" runat="server" AllowPaging="True" AllowSorting="True"
                            AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CourseID" DataSourceID="ObjectDataClasses"
                            ForeColor="#333333" GridLines="None" EmptyDataText="<div class='GridViewNoData'>No Data</div>"
                            Visible="False" Width="520px" OnSelectedIndexChanged="GridViewClasses_SelectedIndexChanged">
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <Columns>
                                <asp:CommandField ShowSelectButton="True" />
                                <asp:BoundField DataField="Title" HeaderText="Class Title" SortExpression="Title" />
                                <asp:BoundField DataField="Subtitle" HeaderText="Class Subtitle" SortExpression="Subtitle" />
                                <asp:CheckBoxField DataField="IsEnabled" HeaderText="Enabled?" SortExpression="IsEnabled">
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:CheckBoxField>
                            </Columns>
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <EditRowStyle BackColor="#999999" />
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        </asp:GridView>
                        <br />
                        <br />
                        <asp:Panel ID="PanelCurrentSection" runat="server" Visible="false">
                            <b>Sections</b>
                            <br />
                            <table>
                                <tr>
                                    <td>
                                        <asp:ListBox ID="lstboxCurrentSection" runat="server" Width="200" SelectionMode="Multiple" />
                                    </td>
                                    <td style="width: 20px;">
                                    </td>
                                    <td>
                                        <asp:LinkButton ID="lnkbtnDeselectSection" runat="server" OnClick="lnkbtnDeselectSection_Click">Click 
                            here to de-select all the sections.</asp:LinkButton><br /><br />
                                        <asp:LinkButton ID="lnkbtnSelectAllSection" runat="server" OnClick="lnkbtnSelectAllSection_Click">Click 
                            here to select all the sections.</asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                            <br />
                            <br />
                            <div style="width: 100%; text-align: center;">
                                <asp:Button ID="btnViewByInstructorUpdate" runat="server" Width="250" Text="Update!"
                                    OnClick="btnViewByInstructorUpdate_Click" />
                            </div>
                            <asp:ObjectDataSource ID="ObjectDataSourceInstructors" runat="server" DeleteMethod="DeleteUserByUserID"
                                OldValuesParameterFormatString="original_{0}" SelectMethod="GetUsersByAccountType"
                                TypeName="UsersBLL" UpdateMethod="UpdateUserByUserID">
                                <DeleteParameters>
                                    <asp:Parameter Name="UserID" Type="Int32" />
                                </DeleteParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="username" Type="String" />
                                    <asp:Parameter Name="accountType" Type="String" />
                                    <asp:Parameter Name="firstName" Type="String" />
                                    <asp:Parameter Name="lastName" Type="String" />
                                    <asp:Parameter Name="studentIDNumber" Type="String" />
                                    <asp:Parameter Name="email" Type="String" />
                                    <asp:Parameter Name="isEnabled" Type="Boolean" />
                                    <asp:Parameter Name="userID" Type="Int32" />
                                </UpdateParameters>
                                <SelectParameters>
                                    <asp:Parameter DefaultValue="Instructor" Name="AccountType" Type="String" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                            <asp:ObjectDataSource ID="ObjectDataSourceAdmins" runat="server" DeleteMethod="DeleteUserByUserID"
                                OldValuesParameterFormatString="original_{0}" SelectMethod="GetUsersByAccountType"
                                TypeName="UsersBLL" UpdateMethod="UpdateUserByUserID">
                                <DeleteParameters>
                                    <asp:Parameter Name="UserID" Type="Int32" />
                                </DeleteParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="username" Type="String" />
                                    <asp:Parameter Name="accountType" Type="String" />
                                    <asp:Parameter Name="firstName" Type="String" />
                                    <asp:Parameter Name="lastName" Type="String" />
                                    <asp:Parameter Name="studentIDNumber" Type="String" />
                                    <asp:Parameter Name="email" Type="String" />
                                    <asp:Parameter Name="isEnabled" Type="Boolean" />
                                    <asp:Parameter Name="userID" Type="Int32" />
                                </UpdateParameters>
                                <SelectParameters>
                                    <asp:Parameter DefaultValue="Admin" Name="AccountType" Type="String" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                            <asp:ObjectDataSource ID="ObjectDataClasses" runat="server" DeleteMethod="DeleteCourse"
                                InsertMethod="InsertCourseSection" OldValuesParameterFormatString="original_{0}"
                                SelectMethod="GetCourses" TypeName="ClassBLL" UpdateMethod="UpdateCourse">
                                <DeleteParameters>
                                    <asp:Parameter Name="courseID" Type="Int32" />
                                </DeleteParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="Title" Type="String" />
                                    <asp:Parameter Name="Subtitle" Type="String" />
                                    <asp:Parameter Name="Introduction" Type="String" />
                                    <asp:Parameter Name="IsEnabled" Type="Boolean" />
                                    <asp:Parameter Name="CourseID" Type="Int32" />
                                </UpdateParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="courseID" Type="Int32" />
                                    <asp:Parameter Name="sectionNumber" Type="Int32" />
                                    <asp:Parameter Name="useSectionInfo" Type="Boolean" />
                                    <asp:Parameter Name="subtitle" Type="String" />
                                    <asp:Parameter Name="introduction" Type="String" />
                                    <asp:Parameter Name="classTime" Type="String" />
                                    <asp:Parameter Name="isEnabled" Type="Boolean" />
                                </InsertParameters>
                            </asp:ObjectDataSource>
                        </asp:Panel>
                        <br />
                    </div>
                </asp:View>
            </asp:MultiView>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
